/*
  Problem 2. Farmer John's Cheese Block
  Description
    Farmer John has a block of cheese in the shape of a cube. It lies on the
    3-dimensional coordinate plane, extending from (0,0,0) to (N,N,N) (2 ≤ N ≤ 1000).
    Farmer John will perform a series of Q (1 ≤ Q ≤ 2 * 10^5) update operations
    to his cheese block.

    For each update operation, FJ will carve out the 1 by 1 by 1 block of cheese
    extending from integer coordinates (x,y,z) to (x+1,y+1,z+1), where 0 ≤ x,y,z < N.
    It is guaranteed that there will exist a 1 by 1 by 1 block of cheese at the
    location FJ carves. Since FJ is playing Moocraft, gravity does not cause
    parts of the cheese to fall if cheese below is carved.

    After each update, output the number of distinct configurations that FJ can
    stick a 1 by 1 by N brick in the cheese block such that no part of the brick
    overlaps with any remaining cheese. Every vertex of the brick must have
    integer coordinates in the range [0,N] for all three axes. FJ may rotate the
    brick however he wants.

  INPUT FORMAT (input arrives from the terminal / stdin):
    The first line contains N and Q.
    The following Q lines contain x, y, and z, the coordinates to be carved.

  OUTPUT FORMAT (print output to the terminal / stdout):
    After each update operation, output an integer, the number of configurations.

  SAMPLE INPUT:
    2 5
    0 0 0
    1 1 1
    0 1 0
    1 0 0
    1 1 0
  SAMPLE OUTPUT:
    0
    0
    1
    2
    5
  hint:
    After the first three updates, the 1×2×1 brick spanning [0,1]×[0,2]×[0,1]
    does not overlap with the remaining cheese, so it contributes toward the answer.

  SCORING:
    Inputs 2-4: N ≤ 10 and Q ≤ 1000
    Inputs 5-7: N ≤ 100 and Q ≤ 1000
    Inputs 8-16: No additional constraints

  Problem credits: Chongtian Ma, Alex Liang

  农夫约翰的奶酪块
  题目描述
    农夫约翰有一块立方体形状的奶酪。它位于三维坐标平面上，从（0, 0, 0）延伸到（N，N，N）
    （2 ≤ N ≤ 1000）。
    约翰将对他的奶酪块执行一系列 Q（1 ≤ Q ≤ 2 * 10^5）更新操作。

    对于每个更新操作，约翰将切出从整数坐标（x，y，z）延伸到（x + 1，y + 1，z + 1）的
    1 * 1 * 1 的奶酪块，其中 0 ≤ x，y、z < N。保证在他雕刻的地方会有一块 1 * 1 * 1 的奶酪。
    由于约翰正在玩 Moocraft，如果下面的奶酪被雕刻，重力不会导致部分奶酪掉落。

    每次更新后，输出约翰可以在奶酪块中粘贴 1 * 1 * N 的砖块的不同配置的数量，
    这些砖块的任何部分都不会与任何剩余的奶酪重叠。
    对于所有三个轴，砖的每个顶点都必须具有 [0，N] 范围内的整数坐标。约翰可以随心所欲地旋转砖块。
  输入格式
    第一行包含 2 个整数 N 和 Q。
    接下来包含 Q 行，每行包含 3 个整数 x, y, z，表示要雕刻的位置点的坐标。
  输出格式
    输出 Q 行, 每行一个整数，表示对应的更新操作后配置数。
  样例输入
    2 5
    0 0 0
    1 1 1
    0 1 0
    1 0 0
    1 1 0
  样例输出
    0
    0
    1
    2
    5
  提示
    在前三次更新后，1 × 2 × 1 的砖块跨度为 [0, 1] × [0, 2] × [0, 1] 不会与剩余的奶酪重叠。
  数据范围
    Inputs 2-4: N ≤ 10 and Q ≤ 1000
    Inputs 5-7: N ≤ 100 and Q ≤ 1000
    Inputs 8-16: 没有其他限制
*/